<div class="userSchools form">
    <?php echo $this->Form->create('UserSchool'); ?>
    <fieldset>
        <legend><?php echo __('Education'); ?></legend>
        <?php
        echo $this->Form->input('UserSchool.0.name');
        echo $this->Form->input('UserSchool.0.city');
        echo $this->Form->input('UserSchool.0.is_primary', array('type' => 'hidden', 'value' => 1));
        echo $this->Form->input('UserSchool.0.state_id');
        echo $this->Form->input('UserSchool.0.zip');
        echo $this->Form->input('UserSchool.0.school_type_id');
        echo $this->Form->input('UserSchool.0.years_at_school');
        echo $this->Form->input('UserSchool.0.grade_level');
        echo $this->Form->input('UserSchool.0.graduated');
        echo $this->Form->input('UserSchool.0.total_schools', array('type' => 'hidden', 'id' => 'total_schools', 'value' => 1));
        ?>
        <div id="school-div">

        </div>
    </fieldset>
    <a href="#" onclick="return false;" id="add-school">Add School</a>
    <?php echo $this->Form->input('Save Draft', array('id' => 'save-draft', 'type' => 'button','class'=>"btn btn-primary")); ?>
    <footer class="signin-actions">
        <input class="btn btn-primary" type='submit' id="submit" value='Next'/>
    </footer>
    <?php echo $this->Form->end(); ?>
</div>
<script>
    $().ready(function() {
        $("#content").on('click', "#add-school", function() {
            var total = $('#total_schools').val();
            $.ajax({url: "<?php echo $this->Html->url(array('controller' => 'users', 'action' => 'add_school', 'em' => false)); ?>/" + total, success: function(result) {
                    $("#school-div").append(result);
                    total++;
                    $('#total_schools').val(total);
                }
            });
        });
        $("#content").on("click", ".remove-school", function() {
            $(this).parent('.school-container').remove();
        });
    });
</script>